﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace SpaceShooter
{
    public class GameExitController
    {
        private ControlState lastState;
        private KeyBehaviour exitKey = new KeyBehaviour()
        {
            GamepadButton = Buttons.Back,
            KeyboardKey = Keys.Escape,
            KeyPressType = KeyPressType.Single
        };

        public bool CheckExitGame()
        {
            var currentState = GameControlHelper.GetCurrentKeyState();

            if (lastState == null)
                lastState = currentState;

            GameControlHelper.GetActiveState(this.exitKey, this.lastState, currentState);

            this.lastState = currentState;

            return exitKey.IsActive;
        }
    }
}
